﻿using System;
using System.Globalization;
using System.Windows.Data;
using GpgApi;

namespace WgpgGUI
{
    [ValueConversion(typeof(GpgDateTime), typeof(Boolean))]
    public sealed class GpgDateTimeToStringConverter : IValueConverter
    {
        public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
        {
            GpgDateTime dt = (GpgDateTime)value;
            if (dt.IsUnlimited)
                return L10N.T("expiration_never");
            return dt.DateTime.Date.ToString("D", CultureInfo.CurrentCulture);
        }

        public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}
